System Logging and NTP Lab
1. Find Log Entries
In this lab, you reconfigure rsyslog to write specific messages to a new log file.
Change the
rsyslogconfiguration to log all messages with severitydebugto/var/log/messages-debugonserver1.example.comby adding the/etc/rsyslog.d/debug.conffile.[root@server1 ~]# echo "*.debug /var/log/messages-debug" > /etc/rsyslog.d/debug.conf
Restart the
rsyslogservice onserver1.example.com.[root@server1 ~]# systemctl restart rsyslog
Monitor
/var/log/messages-debugwith thetailcommand onserver1.example.com.[root@server1 ~]# tail -f /var/log/messages-debug
In a separate terminal window, use the
loggercommand to generate a debug message onserver1.example.com.[root@server1 ~]# logger -p user.debug "Debug Message Test"
Switch back to the terminal still running the
tail -f /var/log/messages-debugcommand and verify the message sent with theloggercommand shows up.[root@server1 ~]# tail -f /var/log/messages-debug ... Feb 13 10:7:44 localhost root: Debug Message Test
2. Find Events with journalctl
In this lab, you filter the systemd journal for specific criteria.
Output only
systemdjournal messages that originate from thesystemdprocess that always runs with process ID1onserver1.example.com.[root@server1 ~]# journalctl _PID=1
Display all
systemdjournal messages that originate from a system service started with user ID81onserver1.example.com.[root@server1 ~]# journalctl _UID=81
Output the journal messages with priority
warningand above onserver1.example.com.[root@server1 ~]# journalctl -p warning
Create a
journalctlquery to show all log events recorded in the previous 10 minutes onserver1.example.com. The command assumes a current time of 9:5:00.[root@server1 ~]# journalctl --since 9:05:00 --until 9:15:00
Display only the events originating from the
sshdservice with the system unit filesshd.servicerecorded since 9:0:00 this morning onserver1.example.com.[root@server1 ~]# journalctl --since 9:00:00 _SYSTEMD_UNIT="sshd.service"
3. Configure a Persistent systemd Journal
In this lab, you make the systemd journal persistent.
Configure the
systemdjournal to be persistent across reboots.Configure the directory
/var/log/journalonserver1.example.com.[root@server1 ~]# mkdir /var/log/journal [root@server1 ~]# chown root:systemd-journal /var/log/journal [root@server1 ~]# chmod 2755 /var/log/journal
Send the
USR1signal tosystemd-journaldor rebootserver1.example.com.[root@server1 ~]# killall -USR1 systemd-journald
To verify the
systemdjournal is persistent, look for a new directory with thesystemdjournal log files that have been written to/var/log/journal. (The exact files which appear on your system may vary, but the directory should have similar contents to the following example.)[root@server1 ~]# ls /var/log/journal/4513ad59a3b442ffa4b7ea88343fa55f system.journal user-1000.journal